#pragma once

#include <gpiod.h>
#include <vector>
#include <string>
#include <chrono>
#include <thread>

#include <stdio.h>
#include <unistd.h>
#include <libserialport.h>

#include <iostream>

#include "rs485_v3.hpp"
#include "agile_modbus_rtu_master.hpp"
#include "yj_return.hpp"
#include "config.h"


typedef struct
{
    uint16_t beep_status;
    uint16_t led_status;
}modbus_led_data_t,*Pmodbus_led_data_t;


typedef enum
{
     MODBUS_LED_BEEP_OFF = 0,
    MODBUS_LED_BEEP_ON = 1,
}modbus_beep_status_en;

typedef enum
{
    MODBUS_LED_ALL_OFF = 0,
    MODBUS_LED_RED_ON = 0x1,
    MODBUS_LED_RED_BLINK_SLOW = 0x2,
    MODBUS_LED_RED_BLINK_FAST = 0x3,
    MODBUS_LED_GREEN_ON = (0x1<<4),
    MODBUS_LED_GREEN_BLINK_SLOW = (0x2<<4),
    MODBUS_LED_GREEN_BLINK_FAST = (0x3<<4),
    MODBUS_LED_BLUE_ON = (0x1<<8),
    MODBUS_LED_BLUE_BLINK_SLOW = (0x2<<8),
    MODBUS_LED_BLUE_BLINK_FAST = (0x3<<8),
    MODBUS_LED_YELLOW_ON = (0x1<<12),
    MODBUS_LED_YELLOW_BLINK_SLOW = (0x2<<12),
    MODBUS_LED_YELLOW_BLINK_FAST = (0x3<<12),
}modbus_led_status_en;


yj_return modbus_led_init(void);
void modbus_led_deinit(void);
yj_return modbus_led_find();
yj_return modbus_led_read_all_status(modbus_led_data_t *data);
yj_return modbus_led_operate_beep(modbus_beep_status_en status);
yj_return modbus_led_operate_led(modbus_led_status_en status);
void modbus_led_print_data(modbus_led_data_t *data);